<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .d2{
            position: absolute;
            top:150px;
            left:410px;
        }
        a{
            display: inline-block;
            width:20px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            background:white;
        }
    </style>
    <script>
        var imgs=["images/ad-01.jpg","images/ad-02.jpg","images/ad-03.jpg","images/ad-04.jpg"];
        var i=0;
        var timer;
        function show(n){
            if(n){
                i=n-1;
                clearTimeout(timer);
            }
            var logo=document.getElementById("logo");//DOM对象
            logo.src=imgs[i];//0  1
            if(i==3){//如果是最后一张图片
                i=0;//从第一张再次开始
            }else{
                i++;//1  2
            }
            timer=setTimeout(show,2000);//函数执行完毕后再次调用show函数
        }
        window.onload=function(){
            show();
        };
    </script>
</head>
<body>
    <div class="d1">
        <img src="images/ad-01.jpg" alt="" id="logo">
    </div>
    <div class="d2">
        <a onmouseover="show(1)">1</a>
        <a onmouseover="show(2)">2</a>
        <a onmouseover="show(3)">3</a>
        <a onmouseover="show(4)">4</a>
    </div>
</body>
</html>